#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "idea.h"

unsigned char k[16] = 
{
	0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
	0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08
};

unsigned char in[8] = 
{
	0x00, 0x00, 0x00, 0x01, 0x00, 0x02,0x00, 0x03
};

unsigned char  c[8] = 
{
	0x11, 0xFB, 0xED, 0x2B, 0x01, 0x98,0x6D, 0xE5
};

unsigned char out[80];

int main(int argc, char *argv[])
{
	IDEA_KEY_SCHEDULE key, dkey; 

	idea_set_encrypt_key(k, &key);
	idea_ecb_encrypt(in, out, &key);
	if (memcmp(out, c, 8) != 0)
	{
		printf("ecb idea error encrypting\n");
		return 20;
	}

	idea_set_decrypt_key(&key, &dkey);
	idea_ecb_encrypt(c, out, &dkey);
	if (memcmp(out, in, 8) != 0)
	{
		printf("ecb idea error decrypting\n");
		return 3;
	}

	printf("ecb idea ok\n");

	return 0;
}

